function plotTS(data,labels,dates)
% plotTS(data,labels,dates) Plot a TS structure
% If data is a TS structure, it uses the dates for the dependent variable and headers for labels
%
% Example:
%     plotTS(my_returns) % my_returns is a TS structure, plots time series data in x-y line chart
%

if nargin < 3, dates = []; end
if nargin < 2, labels = []; end

if isstruct(data)
  labels = data.header;
  dates = TSdatenum(data.dates);
  pdata = data.data;
else
  pdata = data;
end

plot(dates,pdata);
f = min(dates);
l = max(dates);
s = floor((l-f)/10);
dtnum = [f+s,f+3*s,f+5*s,f+7*s,f+9*s];
datelbl = datestr(dtnum,'mmm-yyyy');
set(gca, 'XTick', dtnum);
set(gca, 'XTickLabel',datelbl);
xlim([min(dates) max(dates)]);
legend1 = legend(labels);
set(legend1,'Location','Northwest');

return